package com.design.design.pattern.structural.facade.v1;

/**
 * 创建外观角色FacdeService 类，对外只开放一个兑换礼物的exchange()方法，
 * 在 exchange() 方法内部整合3个子系统的所有功能
 */
public class FacadeService {
    private ScoreSystem scoreSystem = new ScoreSystem();
    private PaymentSystem paymentSystem = new PaymentSystem();
    private LogisticsSystem logisticsSystem = new LogisticsSystem();

    public void exchange(GiftInfo giftInfo) {
        if (scoreSystem.isAvailable(giftInfo)) {
            if (paymentSystem.pay(giftInfo)) {
                String deliveryNO = logisticsSystem.delivery(giftInfo);
                System.out.println("商品兑换成功，物流单号是：" + deliveryNO);
            }
        }
    }
}
